﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace XnaSuperGame
{
	public class Background
	{
		public Background()
		{
// 			bg1StartPos.X=0;
// 			bg1StartPos.Y=0;
// 			bg2StartPos.X=0;
// 			bg2StartPos.Y=0;
// 			bg1CurrentPos.X=0;
// 			bg1CurrentPos.Y=0;
// 			bg2CurrentPos.X=0;
// 			bg2CurrentPos.Y=0;
		}

		public bool LoadContent(Texture2D bg1tx, Texture2D bg2tx)
		{
			_bgTexture1 = bg1tx;
			_bgTexture2 = bg2tx;

			bg1CurrentPos = new Vector2(0, 0);
			bg2CurrentPos = new Vector2(_bgTexture1.Width, 0);

			return true;
		}

		public void Draw(SpriteBatch spriteBatch, GameWindow window)
		{
			Rectangle drawrect = new Rectangle(
				(int)bg1CurrentPos.X,
				(int)bg1CurrentPos.Y,
				window.ClientBounds.Width,
				window.ClientBounds.Height);

			spriteBatch.Draw(_bgTexture1, drawrect, Color.White);


			Rectangle drawrect2 = new Rectangle(
				(int)bg1CurrentPos.X+ 1024, 
				(int)bg1CurrentPos.Y,
				window.ClientBounds.Width, 
				window.ClientBounds.Height
				);
			spriteBatch.Draw(_bgTexture2, drawrect2, Color.White);
// 			window.ClientBounds.Width;
// 			spriteBatch.Draw(_bgTexture1, , Color.White);
		}

		public void Update(GameTime gt)
		{
			bg1CurrentPos.X-=1;
			if (bg1CurrentPos.X <= -1024)
			{
				bg1CurrentPos.X = 0;
			}
		}

		public Texture2D _bgTexture1;
		public Texture2D _bgTexture2;
		public Vector2 bg1CurrentPos;
		public Vector2 bg2CurrentPos;
	}
}

